<extend name="Common:grid"/>
<!-- 
 ------------------------------------------------------
  内容列表页面
 ------------------------------------------------------
 -->
<block name="beforeGrid">
var module=null;
if(isEmpty(module)){
	module=getJqgridStringData(BASE+"/admin/content/key_value","module");
}
var admin=null;
if(isEmpty(admin)){
	admin=getJqgridStringData(BASE+"/admin/content/key_value","admin");
}
</block>

<block name="extOptions">
$.extend(defaultJqGridOptions,{
	colModel:[
		{name:"id",index:"id",width:60,align:"center",sortable:true,editable:false,search:true,searchoptions:{sopt:["eq","ne","gt","lt","le","ge"]}},
		{name:"mid",index:"mid",width:80,align:"center",sortable:true,editable:false,edittype:"select",
			formatter:"select",editoptions:{value:module},search:true,stype:"select",searchoptions:{value:addNoLimit(module),sopt:["eq","ne"]}},
		{name:"uid",index:"uid",width:80,align:"center",sortable: true,editable:false,edittype:"select",
			formatter:"select",editoptions:{value:admin},search:true,stype:"select",searchoptions:{value:addNoLimit(admin),sopt:["eq","ne"]}},
		{name:"title",index:"title",width:100,align:"left",sortable:false,editable:true,edittype:"text",
			editrules:{required:true},search:true,searchoptions:{sopt:["eq","ne","bw","ew","cn"]}},
		{name:"content",index:"content",hidden:true},
		{name:"dateline",index:"dateline",width:70,align:"center",sortable: false,editable:true,formatter:"date",editoptions:{dataInit:function(e){initTime(e);}},
			formatoptions:{srcformat:"u",newformat:"Y-m-d"},
			search:true,searchoptions:{sopt:["eq","ne","gt","lt","le","ge"],dataInit:function(e){initTime(e)}}},
		{name:"top",index:"top",width:80,align:"center",sortable:true,editable:true,edittype:"select",
		    formatter:"select",editoptions:{value:"0:否;1:是"},search:true,stype:"select",searchoptions:{value:"1:是;0:否",sopt:["eq","ne"]}},
		{name:"comments",index:"comments",width:60,align:"right",sortable: true,editable:false,
			search:true,searchoptions:{sopt:["eq","gt","lt","le","ge"]}},
		{name:"views",index:"views",width:60,align:"right",sortable: true,editable:false,
			search:true,searchoptions:{sopt:["eq","gt","lt","le","ge"]}},
		{name:"more",width:60,align:"center",hidden:<if condition="$layout eq 'load'">true<else/>false</if>,sortable:false,editable:false,formatter:actionLinksFormatter,
			viewable:false,formatoptions:{
				items:[{
						title:"查看文章内容",
						onclick:"viewPost(this);",
						className:"ui-icon-document"
					},
					{
						title:"编辑文章内容",
						onclick:"editPost(this);",
						className:"ui-icon-pencil"
					}
					]
				}
			,search:false
		}
	],
	rowNum:30,				
	rowList:[30,60,90], 
	multiselect:<if condition="$layout eq 'load'">false<else/>true</if>
});
$.extend(defaultPagerVisiableOptions,{"add":false,"search":true});
</block>

<block name="afterGrid">
$("#{$layout}_{$Think.ACTION_NAME}_table").jqGrid("filterToolbar").jqGrid('bindKeys');
</block>

<block name="extFunction">
//菜单名称
var editMenuName="文章编辑";
function viewPost(link){
	var tid=$(link).attr("rowId");
	$("#{$layout}_{$Think.ACTION_NAME}_table").jqGrid("setSelection",tid);
	var row=$("#{$layout}_{$Think.ACTION_NAME}_table").getRowData(tid);
	var dialog=artDialog(row.content,row.title);
	dialog.size(800,$(window).height()*0.9);
	dialog.follow("#header");
	$(".d-main").css({"overflow-y":"scroll","display":"inline-block"});
}
function editPost(link){
	var tid=$(link).attr("rowId");
	$("#post_list_table").jqGrid("setSelection",tid);
	var menuid=$("#menu").find("td[title='"+editMenuName+"']").prev().html();
	openTab(menuid,editMenuName,BASE+"/admin/content/post_edit?tid="+tid,function(){},true)
}
</block>